//
//  choicenessTableViewCell.m
//  LubanWork
//
//  Created by xiaohao on 2020/1/1.
//  Copyright © 2020 xiaohao. All rights reserved.
//

#import "choicenessTableViewCell.h"

@implementation choicenessTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style
                    reuseIdentifier:reuseIdentifier]) {
        [self setFrame];
    }
    return self;
    
}

-(void)setFrame{
    [self addSubview:self.backgourd];
    [self.backgourd addSubview:self.titLab];
    [self.backgourd addSubview:self.priceLab];
    [self.backgourd addSubview:self.signLab];
    [self.backgourd addSubview:self.signImg];
    self.backgourd.userInteractionEnabled = YES;
    [self.backgourd addSubview:self.willSignLab];
    [self.backgourd addSubview:self.totalLab];
    [self.backgourd mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(kSCRATIO(5));
        make.left.mas_offset(kSCRATIO(25));
        make.width.mas_offset(WIDTH-kSCRATIO(50));
        make.height.mas_offset(KSCHEIGHT(120));
    }];
    [self.titLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(kSCRATIO(25.5));
        make.top.mas_offset(KSCHEIGHT(9.5));
    }];
    [self.priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.titLab.mas_left);
        make.top.mas_equalTo(self.titLab.mas_bottom).mas_offset(KSCHEIGHT(15));
    }];
    [self.signLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.priceLab.mas_centerY);
        make.left.mas_equalTo(self.priceLab.mas_right).mas_equalTo(1);
    }];
    [self.signImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.priceLab.mas_bottom).mas_offset(KSCHEIGHT(14));
        make.left.mas_equalTo(self.priceLab);
        make.width.mas_offset(kSCRATIO(109));
        make.height.mas_offset(KSCHEIGHT(34));
    }];
    [self.willSignLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.priceLab.mas_bottom).mas_offset(-KSCHEIGHT(15));
        make.right.mas_equalTo(self.backgourd.mas_right)
        .mas_offset(kSCRATIO(-19.5));
        
    }];
    [self.totalLab mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(self.willSignLab);
        make.top.mas_equalTo(self.willSignLab.mas_bottom).mas_offset(KSCHEIGHT(29));
        
    }];
}
-(UILabel *)priceLab{
    if (!_priceLab) {
        _priceLab = [UILabel CreatLabeltext:@"11" Font:[UIFont fontWithName:@"DINAlternate-Bold" size:18] Textcolor:ColorWhite textAlignment:NSTextAlignmentLeft];
    }
    return _priceLab;
}
-(UILabel *)titLab{
    if (!_titLab) {
        _titLab = [UILabel CreatLabeltext:@"手机网络平台刷单，佣金立结。" Font:[UIFont fontWithName:@"Helvetica-Bold" size:15] Textcolor:kColorFromRGBHex(0xFFFFFF) textAlignment:NSTextAlignmentLeft];
    }
    return _titLab;
}
-(UILabel *)signLab{
    if (!_signLab) {
        _signLab = [UILabel CreatLabeltext:@"元/天" Font:kFONT(12) Textcolor:ColorWhite textAlignment:NSTextAlignmentLeft];
    }
    return _signLab;
}
- (UILabel *)willSignLab{
    if (!_willSignLab) {
        _willSignLab = [UILabel CreatLabeltext:@"已报名:6666人" Font:[UIFont fontWithName:@"Helvetica-Bold" size:12] Textcolor:kColorFromRGBHex(0xFFFFFF) textAlignment:NSTextAlignmentLeft];
    }
    return _willSignLab;
}
- (UIButton *)signImg{
    if (!_signImg) {
        _signImg = [UIButton buttonWithType:UIButtonTypeCustom];
        [_signImg setBackgroundImage:[UIImage imageNamed:@"choice_signimg"] forState:UIControlStateNormal];
        [_signImg addTarget:self action:@selector(clickWithEven:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _signImg;
}

- (UILabel *)totalLab{
    if (!_totalLab) {
        _totalLab = [UILabel CreatLabeltext:@"日结丨长期丨男女不限" Font:[UIFont fontWithName:@"Helvetica-Bold" size:12] Textcolor:kColorFromRGBHex(0xFFFFFF) textAlignment:NSTextAlignmentLeft];
    }
    return _totalLab;
}
- (UIImageView *)backgourd{
    if (!_backgourd) {
        _backgourd = [[UIImageView alloc] init];
        _backgourd.backgroundColor = [UIColor blackColor];
        ViewRadius(_backgourd, 10);
    }
    return _backgourd;
}

-(void)clickWithEven:(UIButton *)sender{
    if (self.delegate && [self.delegate respondsToSelector:@selector(clickWithDiselectWithCell:)]) {
        [self.delegate clickWithDiselectWithCell:self];
    }
}



@end
